package business.impl;

import java.sql.ResultSet;
import java.util.List;

import model.AnnexB;
import model.TcascadeInfo;
import business.basic.iHibBaseDAO;
import business.basic.iHibBaseDAOImpl;
import business.dao.CascadeDao;

public class CascadeDaoImpl implements CascadeDao {
	
	iHibBaseDAO bdao = null;
	public void setBdao (iHibBaseDAO bdao){
		this.bdao=bdao;
		
	}

	@Override
	public TcascadeInfo getWorkById(int id) {
		TcascadeInfo modl = (TcascadeInfo) bdao.findById(TcascadeInfo.class,id);
		return modl;
	}

	@Override
	public int addwork(TcascadeInfo model) {
		Object obj = bdao.insert(model);
		if (obj == null) {
			return 0;
		}
		return 1;
	}

	@Override
	public boolean upWork(TcascadeInfo model) {
		return bdao.update(model);
	}

	@Override
	public boolean delWork(int id) {
		return bdao.delete(TcascadeInfo.class, id);
	}

	@Override
	public List<TcascadeInfo> getWorklistBysId(int id) {
		String sql = "from TcascadeInfo where parentid =   ? ";
		Object[] para = {id};		
		List<TcascadeInfo> modl = bdao.select(sql,para);	
		return modl;
	}

	@Override
	public List<TcascadeInfo> getWorklistBylevl(int level) {
		String sql = "from T_cascadeInfo where grade =   ? ";
		Object[] para = {level};
		List<TcascadeInfo> modl =  bdao.select(sql,para);	
		return modl;                                                                                          
	}

}
